<template>
	<view style="width: 100%;height: 100vh;background-color: #f1f1f1;">
		<view class="theme-container" style="width: 100%;padding: 0 10px;margin-bottom: 10px;">
			<!-- 顶部占位 -->
			<view :style="'height:'+sConf.tH+'px;'"> </view>
		</view>
		<scroll-view scroll-y style="width: 100%;height: 100vh;">
			<view style="display: flex;flex-direction: column;width: 100%;padding: 10px;gap: 10px;">
				<sub-message-invite v-for="(item,index) in dataInvite" :key="index" :data="item"
					@stateChange="reloadChange"></sub-message-invite>
				<sub-message-sems v-for="(item,index) in dataMessage" :key="index" :data="item"
					@stateChange="reloadChange"></sub-message-sems>
				<tn-empty v-if="dataInvite.length === 0 && dataMessage.length === 0" mode="message"></tn-empty>
			</view>
		</scroll-view>
		<!-- 顶部自定义导航 -->
		<tn-navbar :placeholder="true" fixed bg-color="#FFFFFF00" text-color="#fff">
			{{sConf.title}}{{title}}
		</tn-navbar>
	</view>
</template>

<script>
	import utils from '@/common/utils';
	export default {
		data() {
			return {
				title: ' • 消息中心',
				sConf: getApp().globalData,
				dataInvite: [], // 邀约消息
				dataMessage: [], // 站内信
			}
		},
		onLoad() {
			this.reloadChange()
		},
		methods: {
			/**
			 * 刷新页面
			 */
			reloadChange() {
				this.loadInviteList(this.sConf.auth.id)
				this.loadMessageList(this.sConf.auth.id)
			},
			/**
			 * 加载邀约请求
			 * @param {Object} e
			 */
			loadInviteList(e) {
				let host = this.sConf.host + '/weapps/invite/';
				let token = this.sConf.token || ''
				let data = {
					sid: e
				}
				utils.authenticatorOnList(host, token, data).then((res) => {
					console.log('邀约请求', res);
					this.dataInvite = res;
				})
			},
			/**
			 * 加载站内信消息
			 */
			loadMessageList(e) {
				let host = this.sConf.host + '/weapps/mesList/';
				let token = this.sConf.token || ''
				let data = {
					sid: e
				}
				utils.authenticatorOnList(host, token, data).then((res) => {
					console.log('邀约请求', res);
					this.dataMessage = res
				})
			}

		}
	}
</script>

<style lang="scss" scoped>

</style>